{include file="public/header" /}
<style type="text/css">
    .uploader-list {

        margin-left: -15px;

    }



    .uploader-list .info {

        position: relative;

        margin-top: -25px;

        background-color: black;

        color: white;

        filter: alpha(Opacity=80);

        -moz-opacity: 0.5;

        opacity: 0.5;

        width: 100px;

        height: 25px;

        text-align: center;

        display: none;

    }



    .uploader-list .handle {

        position: relative;

        background-color: black;

        color: white;

        filter: alpha(Opacity=80);

        -moz-opacity: 0.5;

        opacity: 0.5;

        width: 100px;

        text-align: right;

        height: 18px;

        margin-bottom: -18px;

        display: none;

    }

    .layui-table td,
    .layui-table th {
        min-width: 100px !important;
    }

    .uploader-list .handle i {

        margin-right: 5px;

    }

    .uploader-list .handle i:hover {

        cursor: pointer;

    }

    .uploader-list .file-iteme {

        margin: 12px 0 0 15px;

        padding: 1px;

        float: left;

    }
</style>

<body>
    <div class="layui-card-body">
        <form class="layui-form" action="" lay-filter="component-form-element">
            <div class="layui-fluid">
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-md12">
                        <div class="layui-card">
                            <div class="layui-card-header">基础信息</div>
                            <div class="layui-card-body layui-row layui-col-space10">
                                <div class="layui-col-md4">
                                    <label class="layui-form-label">客户姓名:</label>
                                    <div class="layui-input-block">
                                        <select name="user_id" lay-verify="required" lay-filter="user_id" lay-search="search">
                                            <option value="">请选择客户账号</option>
                                            {foreach $user as $v}
                                            <option value="{$v.id}" {if !empty($row.user_id) &&
                                                $row.user_id==$v.id}selected{/if}>{:config('config.cangku')[$v.type]}/{$v.name|default=''}({$v.mobile|default=''})</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <label class="layui-form-label">商行:</label>
                                    <div class="layui-input-block">
                                        <select name="firm_id" lay-verify="required" lay-filter="firm_id" lay-search="search">
                                            <option value="">请选择商行</option>
                                            {foreach $firm as $v}
                                            <option value="{$v.id}" {if !empty($row.firm_id) &&
                                                $row.firm_id==$v.id}selected{/if}>{$v.name|default=''}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <label class="layui-form-label">入库日期:</label>
                                    <div class="layui-input-block">
                                        <input type="text" id="test" name="times" required="" lay-verify="required"
                                            autocomplete="off" class="layui-input" value="{$row.times|default=''}"
                                            placeholder="">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-card">
                            <div class="layui-card-header">订单金额信息</div>
                            <div class="layui-card-body layui-row layui-col-space10">
                                <div class="layui-col-md3">
                                    <label class="layui-form-label">商行件数(件):</label>
                                    <div class="layui-input-block">
                                        <input type="number" name="number" required="" lay-verify="required"
                                            autocomplete="off" class="layui-input" value="{$row.number|default='0'}"
                                            placeholder="">
                                    </div>
                                </div>
                                <div class="layui-col-md3">
                                    <label class="layui-form-label">商行金额(元):</label>
                                    <div class="layui-input-block">
                                        <input type="number" name="total" required="" lay-verify="required"
                                            autocomplete="off" class="layui-input" value="{$row.total|default='0'}"
                                            placeholder="">
                                    </div>
                                </div>
                                <div class="layui-col-md3">
                                    <label class="layui-form-label">实发件数(件):</label>
                                    <div class="layui-input-block">
                                        <input type="number" name="anumber" required="" lay-verify="required"
                                            autocomplete="off" class="layui-input" value="{$row.anumber|default='0'}"
                                            placeholder="">
                                    </div>
                                </div>
                                <div class="layui-col-md3">
                                    <label class="layui-form-label">实发金额(元):</label>
                                    <div class="layui-input-block">
                                        <input type="number" name="atotal" required="" lay-verify="required"
                                            autocomplete="off" class="layui-input" value="{$row.atotal|default='0'}"
                                            placeholder="">
                                    </div>
                                </div>
                                <div class="layui-col-md3">
                                    <label class="layui-form-label">仓库件数(件):</label>
                                    <div class="layui-input-block">
                                        <input type="number" name="snumber" required="" lay-verify="required"
                                            autocomplete="off" class="layui-input" value="{$row.snumber|default='0'}"
                                            placeholder="">
                                    </div>
                                </div>
                                <div class="layui-col-md3">
                                    <label class="layui-form-label">仓库金额(元):</label>
                                    <div class="layui-input-block">
                                        <input type="number" name="stotal" required="" lay-verify="required"
                                            autocomplete="off" class="layui-input" value="{$row.stotal|default='0'}"
                                            placeholder="">
                                    </div>
                                </div>
                                <div class="layui-col-md3">
                                    <label class="layui-form-label">退货件数(件):</label>
                                    <div class="layui-input-block">
                                        <input type="number" name="rnumber" required="" lay-verify="required"
                                            autocomplete="off" class="layui-input" value="{$row.rnumber|default='0'}"
                                            placeholder="">
                                    </div>
                                </div>
                                <div class="layui-col-md3">
                                    <label class="layui-form-label">退货金额(元):</label>
                                    <div class="layui-input-block">
                                        <input type="number" name="rtotal" required="" lay-verify="required"
                                            autocomplete="off" class="layui-input" value="{$row.rtotal|default='0'}"
                                            placeholder="">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-card">
                            <div class="layui-card-header">付款状态等信息</div>
                            <div class="layui-card-body layui-row layui-col-space10">
                                <div class="layui-col-md6">
                                    <label class="layui-form-label">是否付款:</label>
                                    <div class="layui-input-block">
                                        {foreach $paystatuss as $k => $v}
                                        <input type="radio" name="paystatus" value="{$k}" title="{$v}" {if
                                            !empty($row.paystatus) && $row.paystatus==$k}checked{/if}>
                                        {/foreach}
                                    </div>
                                </div>
                                <div class="layui-col-md6">
                                    <label class="layui-form-label">付款方式:</label>
                                    <div class="layui-input-block">
                                        <select name="payment" lay-verify="">
                                            <option value="">请选择付款方式</option>
                                            {foreach $payments as $k => $v}
                                            <option value="{$k}" {if !empty($row.payment) &&
                                                $row.payment==$k}selected{/if}>
                                                {$v}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-card layui-form" lay-filter="component-form-element">
                            <div class="layui-card-header">进货单</div>
                            <div class="layui-card-body layui-row layui-col-space10">
                                <div class="layui-col-md12">
                                    <div class="layui-upload">
                                        <button type="button" class="layui-btn layui-btn-normal  layui-btn-sm"
                                            id="test2">图片上传</button>
                                        <blockquote class="layui-elem-quote layui-quote-nm"
                                            style="margin-top: 10px;width: 88%">
                                            预览图：
                                            <div class="layui-upload-list uploader-list" style="overflow: auto;"
                                                id="uploader-list">
                                                {if !empty($row.images)}
                                                {foreach $row.images as $v}
                                                <div class="file-iteme">
                                                    <div class="handle" style="display: none;">
                                                        <i class="layui-icon layui-icon-delete"></i>
                                                    </div><img style="width: 100px;height: 100px;" src="{$v}">
                                                    <input type="hidden" name="images[]" value="{$v}">
                                                </div>
                                                {/foreach}
                                                {/if}
                                            </div>
                                        </blockquote>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-card">
                            <div class="layui-card-header">备注信息:</div>
                            <div class="layui-card-body layui-row layui-col-space10">
                                <textarea name="remark" placeholder=""
                                    class="layui-textarea">{$row.remark|default=''}</textarea>
                            </div>
                        </div>
                        <div class="layui-card">
                            <div class="layui-card-header">经办人:</div>
                            <div class="layui-card-body layui-row layui-col-space10">
                                <input type="text" name="jsr" required="required" lay-verify="required" autocomplete="off"
                                    class="layui-input" value="{$row.jsr|default=''}" placeholder="">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input type="hidden" value="{$row['id']|default='0'}" name="id" />
                    <button class="layui-btn" lay-submit="" lay-filter="add">提交</button>
                    <!-- <button type="reset" class="layui-btn layui-btn-primary">重置</button> -->
                </div>
            </div>
        </form>
    </div>
    {include file="public/footer" /}
    <script src="/static/leyedit/Layui-KnifeZ/layui.all.js"></script>
    <script src="/static/leyedit/ace/ace.js"></script>
    <script>
        // 删除图片
        $(document).on("click", ".file-iteme .handle", function (event) {
            $(this).parent().remove();
        });
        $(document).on("mouseenter mouseleave", ".file-iteme", function (event) {
            if (event.type === "mouseenter") {
                //鼠标悬浮
                $(this).children(".info").fadeIn("fast");
                $(this).children(".handle").fadeIn("fast");
            } else if (event.type === "mouseleave") {
                //鼠标离开
                $(this).children(".info").hide();
                $(this).children(".handle").hide();
            }
        });
        layui.extend({
            // 加载自定义模块
            layarea: '{/}/layuiadmin/modules/layarea',
        }).use(['layer', 'jquery', 'form', 'laydate', 'layarea', 'upload'], function () {
            $ = layui.jquery;
            var form = layui.form
                , upload = layui.upload
                , laydate = layui.laydate,
                layarea = layui.layarea
                , layer = layui.layer;
            layarea.render({
                elem: '#area-picker',
                change: function (res) {
                    console.log(11);
                    //选择结果
                }
            });
            laydate.render({
                elem: '#test'
                , type: 'date'
            });
            var demoListView = $('#demoList'),
                uploadListIns = upload.render({
                    elem: '#test2'
                    , url: '/Base/upload_img'
                    , multiple: true
                    , before: function (obj) {
                        layer.msg('图片上传中...', {
                            icon: 16,
                            shade: 0.01,
                            time: 0
                        })
                    }
                    , done: function (res) {
                        if (res.status == 0) {
                            //上传完毕
                            $('#uploader-list').append(
                                '<div id="" class="file-iteme">' +
                                '<div class="handle"><i class="layui-icon layui-icon-delete"></i></div>' +
                                '<img style="width: 100px;height: 100px;" src=' + res.data.src + '>' +
                                '<input type="hidden" name="images[]" value="' + res.data.src + '"></div>'
                            );
                        }
                        layer.close(layer.msg());//关闭上传提示窗口
                    }
                });
            //监听提交
            form.on('submit(add)', function (data) {
                $.ajax({
                    'type': 'post',
                    data: data.field,
                    success: function (res) {
                        if (res.code == 0) {
                            layer.msg(res.msg, { icon: 6, time: 1000 }, function () {
                                // 获得frame索引
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.location.reload();
                                parent.layer.close(index);
                            });
                        } else {
                            layer.msg(res.msg, { icon: 2, time: 1000 });
                        }
                    }
                });
                return false;
            });
        });
    </script>

</body>

</html>